// Create the request object
var xml = new XMLHttpRequest();

// Open the asynchronous POST request
xml.open("GET", "data.js", true);

// Watch for when the state of the document gets updated
xml.onreadystatechange = function(){
	//console.log(xml.readyState + ' : ' + xml.responseText);
    // Wait until the data is fully loaded
    if ( xml.readyState == 4 ) {
    	console.log(httpSuccess(xml));
    	console.log(xml.responseText);
    	console.log(xml.responseXML);

        // xml.responseXML contains the XML Document (if one was returned)
        // xml.responseText contains the response text (if no XML document was provided)

        // Clean up after ourselves, to avoid memory leaks
        xml = null;
    }
};
// Establish the connection to the server
xml.send();

var timeoutLength = 500;

setTimeout(function() {
	console.log(httpSuccess(xml));
}, timeoutLength)